Number.prototype[Symbol.iterator] = function* () {
  let index = 0;
  while (index < this) {
    yield (index += 1);
  }
};
const originalFetch = globalThis.fetch;
globalThis.fetch = (url, options) => {
  let timer;
  const abortController = new AbortController();
  timer = setTimeout(() => {
    abortController.abort();
  }, options?.timeout ?? 6000);
  return originalFetch(url, {
    ...options,
    signal: abortController.signal,
  })
    .then(res => {
      clearTimeout(timer);
      return res;
    })
    .catch(err => {
      clearTimeout(timer);
      throw err;
    });
};
